<?php

namespace api\wxapp\model;

use think\Model;
class Order extends Model
{
    protected $table = 'sssc_app_goods_order';
    public function leftuser($query)
    {
        return $query->join('app_user t2','t2.id = t1.uid');
    }
    public function leftshop($query)
    {
        return $query->join('app_shop t3','t3.id = t1.shop_id');
    }
    //
    public function returnfield($query)
    {
        return $query->field('t1.*,t2.nickname,t2.phone,t3.name');
    }
    public function orderId($query)
    {
        return $query->order('t1.id desc');
    }

    public function getList($where)
    {
        $data = Order::where($where)->field('score,orderNum,status,id,pay_price,shop_id')->select();
        foreach($data as $k=>$v){
            $data[$k]['list'] = OrderList::alias('t1')
                ->join('goods t2','t2.id = t1.goods_id')
                ->field('t1.num,t1.score,t1.price,t2.name,t2.img,t1.para')
                ->where('order_id',$v['id'])
                ->select();
        }
        return $data;
    }
}
